package com.example.administrator.shzs.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;


/**
 * 定义dialog弹出对话框的工具类
 * Created by lanouhn on 16/7/28.
 */
public class DialogUtils
{
    //定义一个显示消息的对话框
    public static void showDialog(final Context context,String msg, boolean goHome)
    {
        //创建一个Dialog.B
        AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(msg).setCancelable(false);
        if (goHome)
        {
         builder.setPositiveButton("确定", new DialogInterface.OnClickListener()
         {
             @Override
             public void onClick(DialogInterface dialogInterface, int i)
             {
                 //检测输入密码是否正确   正确时候进行跳转
//                 Intent intent = new Intent(context, MainActivity.class);
//                 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//                 context.startActivity(intent);
//                 Toast.makeText(context, "11", Toast.LENGTH_SHORT).show();

             }
         });
        }else{
            builder.setPositiveButton("确定",null);
        }
        builder.create().show();
    }
    //定义一个显示指定组建的对话框
    public static void showDialog(Context context,View view){
        new AlertDialog.Builder(context).setView(view).setCancelable(false)
                .setPositiveButton("确定",null).create().show();
    }

    /**
//     *
//     */
    public static void showDialog2(final Context context,String msg, boolean goHome) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(msg).setCancelable(false);

        //设置图标
//        builder.setIcon(R.mipmap.ic_launcher);
        //设置标题
//        builder.setTitle("提示");
            builder.setPositiveButton("不想兑换了", new DialogInterface.OnClickListener()
            {
                @Override
                public void onClick(DialogInterface dialogInterface, int i)
                {
//                    //检测输入密码是否正确   正确时候进行跳转
//                    Intent intent = new Intent(context, MainActivity.class);
//                    intent.putExtra("symbol",3);
//                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//                    context.startActivity(intent);
                }
            });
            builder.setNeutralButton("关闭当前页面", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
//            builder.setPositiveButton("继续逛逛",null);

        //创建并显示
        builder.create().show();
    }
}
